<!DOCTYPE HTML>
<html>
<head>
<#include "/adminPage/common.html"/>
<link rel="stylesheet" type="text/css" href="${ctx}/lib/jsdifflib/diffview.css" />
<style type="text/css">
.layui-form-label {
	width: 140px;
}

.layui-input-block {
	margin-left: 170px;
}

.name {
	padding: 10px;
	padding-left: 0px;
	font-size: 16px;
}

.title {
	margin-top: 5px;
	margin-bottom: 5px;
	height: 30px;
	line-height: 30px;
	cursor: pointer;
}

table.diff {
	width: 100%;
}

.long {
	width: 150px !important;
}

.layui-form-radio {
	width: 700px;
}

input[type='radio'] {
	width: 1000px;
}
</style>
</head>
<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">

		<#include "/adminPage/header.html"/>
		<#include "/adminPage/menu.html"/>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<fieldset class="layui-elem-field layui-field-title">
				<legend>SSO-OAuth2.0配置</legend>
			</fieldset>
			<form id="addForm" style="margin-top: 48px">

				<div class="layui-form-item">
					<label class="layui-form-label">${ssoStr.codeAddr}</label>
					<div class="layui-input-block">
						<input type="text" name="codeUrl" id="codeUrl" class="layui-input" value="${codeUrl}">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">${ssoStr.tokenAddr}</label>
					<div class="layui-input-block">
						<input type="text" name="tokenUrl" id="tokenUrl" class="layui-input" value="${tokenUrl}">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">${ssoStr.userinfoAddr}</label>
					<div class="layui-input-block">
						<input type="text" name="userinfoUrl" id="userinfoUrl" class="layui-input" value="${userinfoUrl}">
					</div>
				</div>


				<div class="layui-form-item">
					<label class="layui-form-label">${ssoStr.jsonpath}</label>
					<div class="layui-input-block">
						<input type="text" name="jsonpath" id="jsonpath" class="layui-input" value="${jsonpath}" placeholder="${ssoStr.placeholder}">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">clientID</label>
					<div class="layui-input-block">
						<input type="text" name="clientID" id="clientID" class="layui-input" value="${clientID}">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">clientSecret</label>
					<div class="layui-input-block">
						<input type="text" name="clientSecret" id="clientSecret" class="layui-input" value="${clientSecret}">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">${ssoStr.callbackAddr}</label>
					<div class="layui-input-block">
						<input id="callbackUrl" name="callbackUrl" class="layui-input">
					</div>
				</div>


				<div class="layui-form-item center">
					<button type="button" class="layui-btn layui-btn-normal" onclick="save()">${commonStr.submit}</button>
				</div>
			</form>

		</div>
	</div>



	<#include '/adminPage/script.html'/>
	<#include '/adminPage/select_root.html'/>
	<script src="${ctx}/lib/auto-line-number/auto-line-number.js" type="text/javascript"></script>
	<script src="${ctx}/lib/jsdifflib/difflib.js" type="text/javascript"></script>
	<script src="${ctx}/lib/jsdifflib/diffview.js" type="text/javascript"></script>
	<script src="${ctx}/lib/base64/base64.js" type="text/javascript"></script>
	<script type="application/javascript">
		

	const href = location.href.split('/');
	const host = href[0]+"//"+href[2];
	document.getElementById("callbackUrl").value=host+"/adminPage/sso/code";//host+"/adminPage/sso/code?code=xxxxxxx";

	async function save(){
		const form = document.getElementById('addForm');
		const formData = new FormData(form);
		const response = await fetch('/adminPage/sso/save', {
			method: 'POST',
			body: formData
		});
		const data = await response.json();
		if (data.success) {
			layer.msg(ssoStr.success)
		}else {
			layer.msg(data.msg)
		}
	}

	</script>
</body>


</html>